
    TestCase
    (
        'ie.ondevice.objectkit.extension.ArrayTestCase'

    ,   {
            
            testClear: function () 
            {
                var list= [1,2,3,4]
                
                assertFalse('The list is not empty', list.isEmpty())
                list.clear();
                
                assertTrue('The list is empty', list.isEmpty())
                assertTrue('The list has zero length', 0 === list.length);
            }
            
        ,   testRemove: function () 
            {
                var item= {}
                ,   list= ['a', item]
                
                assertTrue('The list has the item', list.contains(item))
                list.remove(item);
                assertFalse('the list does not have the item', list.contains(item));
                assertTrue('The list has only one item and its value is a', 'a' === list[0] && 1 === list.length);
            }
            
        ,   testRemoveAll: function () 
            {
                var item= {}
                ,   list= [1, item, 2, item];
                
                assertTrue('The list contains the item', list.contains(item));
                list.remove(item);
                assertTrue('The list sill contains a reference to the item', list.contains(item));
                list.push(item);
                assertSame('The array has a length of 4', 4, list.length);
                // [item, 1, item, 2]
                list.removeAll(item);
                
                //assertFalse(list, true)
                
                assertFalse('The list no longer contains the item', list.contains(item));
                assertSame('The list now has a length of 2', 2, list.length);
                assertSame('The first item is the number 1', 1, list.first());
                assertSame('The second item is the number 2', 2, list.last());
            }
            
        ,   testContains: function () 
            {
                var item= {}
                ,   list= [1, 2, item, 3]
                
                assertTrue('The list contains the item', list.contains(item));
                
                list.splice(2, 1);
                
                assertFalse('The list does not contain the item', list.contains(item));
                assertTrue('The list contains the number 1', list.contains(1));
                
                list= [];
                
                assertFalse('Empty arrays always return false', list.contains(0));
            }
            
        ,   testIsEmpty: function () 
            {
                var list= [1]
                ,   alloted= new Array(5)
                
                assertUndefined('The first value in an alloted array is undefined', alloted[0])
                
                assertTrue('New arrays are always empty', [].isEmpty());
                assertTrue('Sparse arrays are considered empty', alloted.isEmpty());
                assertFalse('Items with at least one item are never empty', list.isEmpty());
            }
            
        ,   testHas: function () 
            {
                var i= 0
                ,   n= 10
                ,   list= []
                
                while (n--) 
                {
                    list.push(new Object);
                    assertTrue('The list has an index of ' + i, list.has(i));
                    i++;
                }
                
                assertSame('The list has 10 items', 10, list.length);
                
            }
            
        ,   testFirst: function () 
            {
                var list= [1];
                assertSame('The first item in the list is the number 1', 1, list.first());
                assertSame('The first item in the list is the same as list[0', list[0], list.first());
                assertSame('In an item of length 1, the first and last are the same', list.first(), list.last());
                
                var error;
                
                try 
                {
                    [].first();
                }
                catch (thrown) 
                {
                    error= thrown;
                }
                
               assertInstanceOf('A range error is thrown retrieving first() from an empty array', RangeError, error);
            }
            
        ,   testLast: function () 
            {
                var list= [1];
                assertSame('The first item in the list is the number 1', 1, list.last());
                assertSame('The first item in the list is the same as list[0', list[0], list.last());
                assertSame('In an item of length 1, the last and first are the same', list.last(), list.first());
                
                var error;
                
                try 
                {
                    [].last();
                }
                catch (thrown) 
                {
                    error= thrown;
                }
                
               assertInstanceOf('A range error is thrown retrieving last() from an empty array', RangeError, error);
            }
            
        ,   testTrim: function () 
            {
                var list= new Array(5)
                ,   item= {}
                
                list.push(item);
                assertSame('The list now has 6 items', 6, list.length);
                list.trim();
                assertSame('The list now as 1 item', 1, list.length);
                assertSame('The first item is a reference to the item variable', item, list.first());
                
            }
        }
    );